with open('file.txt', 'w') as f:
    print('create a file and write some content.')
    for i in range(5):
        f.write(str(i+1) + '.line content.\n')
        
with open('file.txt') as f:
    print('some contents from \"file.txt\" are here.')
    for line in f:
        print(line)
